namespace Chaliy.Syndication.MediaRss
{
	using System;
	using System.Xml;
	using System.Xml.Schema;
	using System.Xml.Serialization;
    using System.Collections.Generic;
    using System.Collections;
	
	/// <summary>
	/// 	Represents publushed content. While many of the attributes appear to be audio/video specific,
	/// 	this element can be used to publish any type of media.
	/// </summary>
	[XmlRoot("content", Namespace = Namespaces.MediaRssPrivate)]
    public sealed class MediaContent : ExtensibleElement
    {
        public Uri Url
        {
            get;
            set;
        }
        
        public int? FileSize
        {
            get;
            set;
        }
        
        public string Type
        {
            get;
            set;
        }
        
        public MediaMedium Medium
        {
            get;
            set;
        }
        
        public bool IsDefault
        {
            get;
            set;
        }
        
        public MediaExpression Expression
        {
            get;
            set;
        }
        
        public int? BitRate
        {
            get;
            set;
        }
        
        public int? FrameRate
        {
            get;
            set;
        }
        
        public double? SamplingRate
        {
            get;
            set;
        }
        
        public int? Channels
        {
            get;
            set;
        }
        
        public int? Duration
        {
            get;
            set;
        }
        
        public int? Height
        {
            get;
            set;
        }
        
        public int? Width
        {
            get;
            set;
        }
        
        public string Language
        {
            get;
            set;
        }

        #region Methods

        protected override void WriteXml(XmlWriter writer)
        {
            ArgumentUtilities.EnsureArgumentNotNull(writer, "writer");

            if (this.Url != null)
            {
                writer.WriteAttributeString("url", this.Url.ToString());
            }

            writer.WriteInt32Attribute("fileSize", this.FileSize);
            writer.WriteStringAttribute("type", this.Type);            
            writer.WriteEnumAttribute("medium", this.Medium);
            writer.WriteBooleanAttribute("isDefault", this.IsDefault);
            writer.WriteEnumAttribute("expression", this.Expression);
            writer.WriteInt32Attribute("bitrate", this.BitRate);
            writer.WriteInt32Attribute("framerate", this.FrameRate);
            writer.WriteDoubleAttribute("samplingrate", this.SamplingRate);
            writer.WriteInt32Attribute("channels", this.Channels);
            writer.WriteInt32Attribute("duration", this.Duration);
            writer.WriteInt32Attribute("height", this.Height);
            writer.WriteInt32Attribute("width", this.Width);
            writer.WriteStringAttribute("lang", this.Language);

            base.WriteXml(writer);
        }

        #endregion  
    }

}
